package com.lainiao.servletContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 *  ServletContext 域对象
 */
@WebServlet("/scs")
public class servletContext01_ServletContextScope extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        // 获取 ServletContext 对象
        ServletContext servletContext = request.getServletContext();
        // 设置域对象
        servletContext.setAttribute("name","liuXing");
        // 获取域对象
        servletContext.getAttribute("name");
        // 移除域对象
        servletContext.removeAttribute("name");
    }
}
